﻿using System;
using AutoMapper;
using ORS.OrderRobot.Domain;
using ORS.OrderRobot.IOC;
using ORS.OrderRobot.ServiceContracts;
using ORS.OrderRobot.ServiceContracts.Dtos;

namespace ORS.OrderRobot.Service
{
	public class ProductMointerLogService: IProductMointerLogService,IScoped
    {
        private readonly IRepository<ProductMointerLog, int> _productMointerLogRepository;
        private readonly IMapper _mapper;
        public ProductMointerLogService(
            IRepository<ProductMointerLog, int> productMointerLogRepository,
            IMapper mapper
        )
		{
            _productMointerLogRepository = productMointerLogRepository;
            _mapper = mapper;
		}

        public async Task<List<ProductMointerLogDto>> GetList(GetProductInput input)
        {
            var dtos = new List<ProductMointerLogDto>();
            var list = await _productMointerLogRepository.GetListAsync(x => input.ProductIds!= null && input.ProductIds.Any() ? input.ProductIds.Contains(x.ProductId) : true);
            return _mapper.Map<List<ProductMointerLogDto>>(list);
        }
    }
}

